package org.kealinghornets.jchuah.buttons;

import android.content.Intent;
import android.media.Image;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;


public class Level2Activity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_level2);
    }

    public void checkVictory(){
    View image1 = findViewById(R.id.image1);
    View image2 = findViewById(R.id.image2);
    if (image1. getVisibility()== View.INVISIBLE && image2.getVisibility() == View.INVISIBLE){
        Toast.makeText(this, "I DON'T LIKE YOU!!", Toast.LENGTH_LONG).show();
        startActivity(new Intent(this, Level3Activity.class));
    }
}

    public void toggleVisibility(int id) {
        View image;

        image = findViewById(id);

        if (image.getVisibility() == View.VISIBLE) {
            image.setVisibility(View.INVISIBLE);
        } else {
            image.setVisibility(View. VISIBLE);
        }
    }



    public void onButton1Push (View view){
        Toast.makeText(this , "button_1", Toast. LENGTH_SHORT).show();
        toggleVisibility(R.id.image1);
        checkVictory();
    }

    public void onButton2Push (View view) {
        Toast.makeText(this,"button_2",Toast. LENGTH_SHORT).show();
        toggleVisibility(R.id. image2);
        checkVictory();
    }

    public void onButton3Push (View view){
        Toast.makeText(this,"button_3",Toast. LENGTH_SHORT).show();
        toggleVisibility(R.id. image2);
        checkVictory();
    }

    public void onButton4Push (View view){
        Toast.makeText(this,"button_4",Toast. LENGTH_SHORT).show();
        toggleVisibility(R.id. image2);
        checkVictory();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_level2, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
